const defaultState={
  inputValue:'Write Something',
  list:[
    '早上8点开晨会,分配今天的任务',
    '中午吃酸菜鱼,顺路帮仔仔打印东西',
    '明天去花都广场,看灯光节',
    '后天产品上线,记得仔细检查代码',
  ]
}
export default (state=defaultState,action)=>{
  //Reducer里只能接收state,不能改变state
  if(action.type==='changeInput'){
    let newState=JSON.parse(JSON.stringify(state))
    newState.inputValue=action.value 
    return newState
  }
  
  if(action.type==='addItem'){
    let newState=JSON.parse(JSON.stringify(state))
    newState.list.push(newState.inputValue)
    newState.inputValue=''
    return newState
  }
  
  if(action.type==='deletelitem'){
    let newState=JSON.parse(JSON.stringify(state))
    newState.list.splice(action.index,1)
    return newState
  }
  
	return state
}